package UI;

import java.util.Random;

public class CodeUtil {
    private CodeUtil() {

    }

    public static String getCode(){
        Random r=new Random();
        StringBuilder sb=new StringBuilder();
        int alternate=r.nextInt(4);
        int num=r.nextInt(10);
        for (int i = 0; i < 4; i++) {
            if(i==alternate){
                sb.append(num);
            }else {
                int opt = r.nextInt(2);
                if (opt == 0) {
                    char a = (char) (r.nextInt(26) + 65);
                    sb.append(a);
                } else {
                    char a = (char) (r.nextInt(26) + 97);
                    sb.append(a);
                }
            }
        }
        return sb.toString();
    }
}
